#ifndef XM_INETADD_HH
#define XM_INETADD_HH

#ifdef __linux__
#include <arpa/inet.h>
#include <netinet/in.h>
#endif // os deps

#include <string>

#include "pch.hh"

XM_NAMESPACE_BEGIN

struct InetAddr
{
    explicit InetAddr(uint16_t port = 0, std::string ip = "127.0.0.1");// TODO: don't use default
    explicit InetAddr(const sockaddr_in& addr) : addr__(addr)
    {}

    std::string toIp() const;
    std::string toIpPort() const;
    uint16_t toPort() const;

    const sockaddr_in* getSockAddr() const
    {
        return &addr__;
    }

    void setSockAddr(const sockaddr_in& addr)
    {
        addr__ = addr;
    }

private:
    sockaddr_in addr__;
};

XM_NAMESPACE_END

#endif // header filr protect